//
//  main.m
//  PostMessa
//
//  Created by never down on 15-5-12.
//  Copyright (c) 2015年 ygy_ios. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "NSNetwork.h"
#import "AppDelegate.h"
#define APP_URL @"https://www.erhuoapp.com/interface/check_for_update/"

int main(int argc, char * argv[]) {
    NSNetwork *net = [[NSNetwork alloc] initWithURL:[NSURL URLWithString:APP_URL] withMethod:_NETWORK_METHOD_POST_ withData:[NSDictionary dictionaryWithObjectsAndKeys:@"1", @"client", nil] withType:_NETWORK_DATA_TYPE_TEXT_];
    [net setTimeoutInterval:10];
    
    [net sendRequest:^(NSURLResponse *response, NSData *result, NSError *error) {
        if (!error) {
            NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:result options:NSJSONReadingMutableLeaves error:nil];
            if (![[dic objectForKey:@"error"] integerValue]) {
                NSString *version = [dic objectForKey:@"version"];
                NSString *addr = [dic objectForKey:@"download"];
                
                //                [[NSUserDefaults standardUserDefaults] setObject:dict forKey:@"user"];
                //                [UMessage addAlias:uid type:kUMessageAliasTypeErhuo response:nil];
                //                [self userInit:dict];
            }else{
                NSLog(@"this incourr a error!");
            }
            
        }
    }];
    
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}
